import matplotlib.pyplot as plt  
import numpy as np

f = open("dataC.txt","r")
n = int(f.readline())
v = list(map(float,f.readline().split()))
lx=[]
ly=[]
content = f.readlines()
for i in range(0,n-1):
    c = list(map(float,content[i].split()))
    x = np.linspace(v[i],v[i+1],100)
    if len(c) == 4:
        y = c[0]*x**3+c[1]*x**2+c[2]*x+c[3]
    else:
        y = c[0]*x+c[1]
    lx.extend(x)
    ly.extend(y)

plt.plot(lx,ly,label='cubic')
x = np.linspace(-5,5,1000)
y = 1/(1+x*x)
plt.plot(x,y,label= r'$\frac{1}{1+x^2}$')

plt.legend()
plt.show()
f.close()